package com.cxg.fairy.ec.main.personal.address;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.SimpleClickListener;
import com.cxg.fairy.ec.main.order.PostOrderDelegate;
import com.cxg.fairy.ui.recycler.MultipleFields;
import com.cxg.fairy.ui.recycler.MultipleItemEntity;
import com.cxg.fairy.util.log.LatteLogger;
import com.cxg.fairy.util.storage.LattePreference;

import java.util.WeakHashMap;

/**
 * Created by Administrator on 2018/4/18.
 */

public class AddressListClickListener extends SimpleClickListener {

    private final AddressListDelegate DELEGATE;

    private final PostOrderDelegate PDELEGATE;

    public AddressListClickListener(AddressListDelegate delegate,PostOrderDelegate pDelegate) {
        this.DELEGATE = delegate;
        this.PDELEGATE = pDelegate;
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        MultipleItemEntity entity = (MultipleItemEntity) baseQuickAdapter.getData().get(position);
        WeakHashMap argsMap = new WeakHashMap();
        argsMap.put("POST_ORDER_NAME_TEL", entity.getField(MultipleFields.NAME)+"  "+entity.getField(AddressItemFields.PHONE));
        argsMap.put("POST_ORDER_ADDRESS", entity.getField(AddressItemFields.ADDRESS));
        argsMap.put("POST_ORDER_ADDRESS_ID", entity.getField(MultipleFields.ID));

        LattePreference.addCustomAppProfile("POST_ORDER_NAME_TEL",entity.getField(MultipleFields.NAME)+"  "+entity.getField(AddressItemFields.PHONE));
        LattePreference.addCustomAppProfile("POST_ORDER_ADDRESS", entity.getField(AddressItemFields.ADDRESS)+"");
        LattePreference.addCustomAppProfile("POST_ORDER_ADDRESS_ID", entity.getField(MultipleFields.ID)+"");
        PDELEGATE.getSupportDelegate().pop();
        DELEGATE.getSupportDelegate().pop();
        DELEGATE.getSupportDelegate().start(PostOrderDelegate.create(argsMap));
    }

    @Override
    public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {

    }
}
